package userlimitRequest

import (
	"arabApi/app/api/requests"
	"github.com/gin-gonic/gin"
	"github.com/thedevsaddam/govalidator"
)

type UserAdd struct {
	ID    int64  `json:"id" form:"id"`
	Name  string `json:"name" form:"name" valid:"name"`
	Email string `json:"email" form:"email" valid:"email"`
	Phone string `json:"phone" form:"phone" valid:"phone"`
	State int64  `json:"state" form:"state"`
}

func CheckUserAdd(data interface{}, c *gin.Context) string {
	// 自定义验证规则
	rules := govalidator.MapData{
		"name": []string{"required"},
		//"email": []string{"required"},
		"phone": []string{"required"},
	}
	// 自定义验证出错时的提示
	messages := govalidator.MapData{
		"name": []string{
			"required:账号名称不能为空",
		},
		//"email": []string{
		//	"required:邮箱不能为空",
		//},
		"phone": []string{
			"required:电话不能为空",
		},
	}

	errs := requests.Validate1(data, rules, messages)
	return requests.GetOneErr(errs)
}
